from flask_wtf import FlaskForm
from wtforms import StringField, BooleanField, SubmitField, TextAreaField
from wtforms.validators import InputRequired, URL, Optional


class EditForm(FlaskForm):
    site_name = StringField('网站名称', validators=[
        InputRequired('不能为空')
    ])
    site_url = StringField(
        '网站链接',
        render_kw={
            'placeholder': '请输入网址，需加http 或 https'
        },
        validators=[
            URL(message='不是正确的网站链接')
        ]
    )
    site_logo = StringField(
        '网站logo',
        render_kw={
            'placeholder': '请输入完整的图片链接'
        },
        validators=[
            Optional(),
            URL(message='网址logo地址不正确')
        ]
    )
    site_person = TextAreaField('负责人')
    site_contact = TextAreaField('联系方式')
    status = BooleanField('启用', default=True)
    save = SubmitField('保存')
